package com.jash.labor.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.jash.labor.context.Result;
import com.jash.labor.entity.Company;
import com.jash.labor.entity.FirstParty;
import com.jash.labor.mapper.CompanyMapper;
import net.sf.jsqlparser.expression.operators.relational.OldOracleJoinBinaryExpression;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import javax.annotation.Resource;
import java.sql.Date;
import java.sql.Timestamp;
import java.util.HashMap;
import java.util.List;


@Service
public class CompanyService {
    @Resource
    private CompanyMapper companyMapper;
    public Object add(Company company){
        company.setCreatetime(new Timestamp(System.currentTimeMillis()));
        companyMapper.insert(company);
        return Result.SUCCESS;
    }
    public Object edit(Company company){
        companyMapper.updateById(company);
        return Result.SUCCESS;
    }

    public Object queryListPage(Integer pageNo, Integer pageSize){
        Page <Company>page = new Page(pageNo,pageSize);
        QueryWrapper wrapper = new QueryWrapper();
        IPage iPage = companyMapper.selectPage(page,wrapper);
        return new Result<>(iPage);
    }
    //查询用工单位列表
    public Object queryFirstPartylist(Integer companyid,Integer pageNo, Integer pageSize) {
//        Page <Company>page = new Page(pageNo,pageSize);
//        QueryWrapper wrapper = new QueryWrapper();
        List<HashMap> list = companyMapper.queryFirstPartylist(companyid);
        return new Result<>(list);
    }
    //查询用工单位详细信息
    public Object companyQueryFirstPartylistById(Integer companyid,Integer pageNo, Integer pageSize) {

//        Page <Company>page = new Page(pageNo,pageSize);
//        QueryWrapper wrapper = new QueryWrapper();
        List<HashMap> list = companyMapper.companyQueryFirstPartylistById(companyid);
        return new Result<>(list);
    }


    public Object companyQueryStationList(String content, Integer pageNo, Integer pageSize) {
        List<HashMap> list = companyMapper.companyQueryStationList(content);
        return new Result<>(list);
    }

    public Object queryCompanyList(String companyid, Integer pageNo, Integer pageSize) {

        return new Result<>(companyMapper.companyQueryStationList(companyid));
    }
}
